package com.example.clothingmanager.controller;

import com.example.clothingmanager.bean.User;
import com.example.clothingmanager.dao.UserDao;
import com.example.clothingmanager.service.LoginService;
import com.example.clothingmanager.service.UserService;
import com.example.clothingmanager.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author Huangyt
 * @version 1.0
 * @date 2020/5/9 23:41
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    LoginService loginService;

    @PostMapping("/check")
    public Result check(@RequestBody User user, HttpSession session){
        return loginService.check(user, session);
    }

    @GetMapping("/get/head")
    public Result getHeadPage(String account){
        return loginService.getHeadPage(account);
    }

    @GetMapping("/out")
    public Result logOut(HttpSession session){
        return loginService.logOut(session);
    }

    @GetMapping("/getuser")
    public Result getUser(HttpSession session){
        return loginService.getUser(session);
    }

    @GetMapping("/getauthorInstock/{account}")
    public Result getAuthorInstock(@PathVariable("account")String account){
        return loginService.getAuthorInstock(account);
    }
}
